package org.bminfo.migle.format;

import java.util.Map;

public class FASTA {
	public String[] fastaParser(String content) {
		String[] line = content.replace("\r","").split("\n");
		String seq = "";
		StringBuilder fasta = new StringBuilder();
		StringBuilder temp = new StringBuilder();
		for(int i=0; i<line.length;i++){
			if(line[i].startsWith(">")){
				fasta.append(line[i] + "\n");
			}else{
				temp.append(line[i].replace(" ", "").toUpperCase());					
			}
		}
		
		seq = temp.toString();
		
		int length = seq.length();
		
		for (int i = 0; i < seq.length(); i++) {
			fasta.append(seq.charAt(i));
			if ((i + 1) % 60 == 0) {
				fasta.append("\n");
			}
		}

		String seqfile = fasta.toString();

		String[] arr = new String[2];
				
		arr[0] = fasta.toString();
		arr[1] = Integer.toString(length);
		
		return arr;
	}
}
